import os, shutil

a = r'D:\Document_x64\Documents\Tencent Files\3418432614\FileRecv\codes'

for root, dirs, files in os.walk(a):
    if len(dirs + files) == 0: os.rmdir(root)
    if 'src' in dirs and 'target' in dirs:
        p = os.path.join(root, 'target')
        print p
        shutil.rmtree(p)
    for i in files:
        if i.endswith('.class'):
            p = os.path.join(root, i)
            print i
            os.remove(p)
